#include <stdio.h>

#include "nolock_queue.h"

int main(void)
{
    int i = 0;
    void *ptr = &i;
    queue_nolock_t *queue = queue_nolock_create(8);
    if(NULL == queue)
    {
        printf("create queue failed!\n");
        return -1;
    }

    printf("start pointer : %p\n", ptr);
    printf("sizeof(void *): %d\n", (int)sizeof(void *));
    printf("queue is empty: %d\n", queue_nolock_empty(queue));
    printf("queue is full : %d\n", queue_nolock_full(queue));
    printf("queue size    : %d\n", queue_nolock_size(queue));

    for(i = 0; i < 3; i++)
        queue_nolock_push(queue, ptr + i);

    printf("\nafter push 3 item:\n");
    printf("queue is empty: %d\n", queue_nolock_empty(queue));
    printf("queue is full : %d\n", queue_nolock_full(queue));
    printf("queue size    : %d\n", queue_nolock_size(queue));

    printf("\npop one item: %p\n", queue_nolock_pop(queue));
    printf("queue is empty: %d\n", queue_nolock_empty(queue));
    printf("queue is full : %d\n", queue_nolock_full(queue));
    printf("queue size    : %d\n", queue_nolock_size(queue));

    for(; i < 10; i++)
        queue_nolock_push(queue, ptr + i);

    printf("\nafter push 7 item:\n");
    printf("queue is empty: %d\n", queue_nolock_empty(queue));
    printf("queue is full : %d\n", queue_nolock_full(queue));
    printf("queue size    : %d\n", queue_nolock_size(queue));

    printf("\npop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    printf("pop one item: %p\n", queue_nolock_pop(queue));
    
    queue_nolock_destroy(queue);
    return 0;
}
